package jf.collections.range;

import java.math.BigDecimal;
import java.util.Iterator;

/**
 * @author ivanalx
 * @date 02.06.2009 17:45:21
 */
public class BigDecimalRange implements Iterable<BigDecimal>{
	private BigDecimal from;
	private BigDecimal to;
	private BigDecimal step;

	public BigDecimalRange(BigDecimal from, BigDecimal to, BigDecimal step) {
		this.from = from;
		this.to = to;
		this.step = step;
	}

	public BigDecimalRange(BigDecimal from, BigDecimal to) {
		this.from = from;
		this.to = to;
		this.step = new BigDecimal(1);
	}

	@Override
	public Iterator<BigDecimal> iterator() {
		return new BigDecimalRangeIterator(from, to, step);
	}

	public static BigDecimalRange range(int from, int to, int step) {
		return new BigDecimalRange(new BigDecimal(from), new BigDecimal(to), new BigDecimal(step));
	}

	public static BigDecimalRange range(int from, int to) {
		return new BigDecimalRange(new BigDecimal(from), new BigDecimal(to));
	}

	public static BigDecimalRange range(double from, double to, double step) {
		return new BigDecimalRange(new BigDecimal(from), new BigDecimal(to), new BigDecimal(step));
	}

	public static BigDecimalRange range(double from, double to) {
		return new BigDecimalRange(new BigDecimal(from), new BigDecimal(to));
	}
	
	public static BigDecimalRange range(long from, long to, long step) {
		return new BigDecimalRange(new BigDecimal(from), new BigDecimal(to), new BigDecimal(step));
	}

	public static BigDecimalRange range(long from, long to) {
		return new BigDecimalRange(new BigDecimal(from), new BigDecimal(to));
	}

	public static BigDecimalRange range(BigDecimal from, BigDecimal to, BigDecimal step) {
		return new BigDecimalRange(from, to, step);
	}

	public static BigDecimalRange range(BigDecimal from, BigDecimal to) {
		return new BigDecimalRange(from, to);
	}
}
